<?php

namespace JsonLowCode\Form;

use Closure;
use JsonLowCode\UI\InputGroup;
use JsonLowCode\Form\Abstract\FormAbstract;

/**
 * @property InputGroup $element
 * @method InputGroup element()
 */
class Group extends FormAbstract
{
    protected function booted(): void
    {
        $this->element = new InputGroup();
    }

    /**
     * @param Closure $children 子元素回调
     * @return $this
     */
    public function item(Closure $children): static
    {
        $formBuilder = new Make($this->build);
        call_user_func($children, $formBuilder);
        $this->element->children($formBuilder);
        return $this;
    }
}
